
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       uitc_vehicle_local_position.h
  * @author     baiyang
  * @date       2023-3-1
  ******************************************************************************
  */

#pragma once

#ifdef __cplusplus
extern "C"{
#endif

/*----------------------------------include-----------------------------------*/
#include <uITC/uITC.h>
/*-----------------------------------macro------------------------------------*/
ITC_DECLARE(vehicle_local_position);

#define VEHICLE_LOCAL_POSITION_DIST_BOTTOM_SENSOR_NONE 0
#define VEHICLE_LOCAL_POSITION_DIST_BOTTOM_SENSOR_RANGE 1
#define VEHICLE_LOCAL_POSITION_DIST_BOTTOM_SENSOR_FLOW 2
/*----------------------------------typedef-----------------------------------*/
typedef struct
{
    uint64_t timestamp;          // time since system start (microseconds)
    uint64_t timestamp_sample;   // the timestamp of the raw data (microseconds)
    uint64_t ref_timestamp;      // Time when reference position was set since system start, (microseconds)
    double ref_lat;              // Reference point latitude, (degrees)
    double ref_lon;              // Reference point longitude, (degrees)
    float x;                     // North position in NED earth-fixed frame, (metres)
    float y;                     // East position in NED earth-fixed frame, (metres)
    float z;                     // Down position (negative altitude) in NED earth-fixed frame, (metres)
    float alt;                   // Altitude AMSL, (meters)
    float delta_xy[2];           // Position reset delta
    float delta_z;               // Position reset delta
    float vx;                    // North velocity in NED earth-fixed frame, (metres/sec)
    float vy;                    // East velocity in NED earth-fixed frame, (metres/sec)
    float vz;                    // Down velocity in NED earth-fixed frame, (metres/sec)
    float z_deriv;               // Down position time derivative in NED earth-fixed frame, (metres/sec)
    float delta_vxy[2];          // Velocity reset delta
    float delta_vz;              // Velocity reset delta
    float ax;                    // North velocity derivative in NED earth-fixed frame, (metres/sec^2)
    float ay;                    // East velocity derivative in NED earth-fixed frame, (metres/sec^2)
    float az;                    // Down velocity derivative in NED earth-fixed frame, (metres/sec^2)
    float heading;               // Euler yaw angle transforming the tangent plane relative to NED earth-fixed frame, -PI..+PI,  (radians)
    float unaided_heading;       // Same as heading but generated by integrating corrected gyro data only
    float delta_heading;
    float ref_alt;               // Reference altitude AMSL, (metres)
    float dist_bottom;           // Distance from from bottom surface to ground, (metres)
    float eph;                   // Standard deviation of horizontal position error, (metres)
    float epv;                   // Standard deviation of vertical position error, (metres)
    float evh;                   // Standard deviation of horizontal velocity error, (metres/sec)
    float evv;                   // Standard deviation of vertical velocity error, (metres/sec)
    float vxy_max;               // maximum horizontal speed - set to 0 when limiting not required (meters/sec)
    float vz_max;                // maximum vertical speed - set to 0 when limiting not required (meters/sec)
    float hagl_min;              // minimum height above ground level - set to 0 when limiting not required (meters)
    float hagl_max;              // maximum height above ground level - set to 0 when limiting not required (meters)
    uint8_t xy_reset_counter;
    uint8_t z_reset_counter;
    uint8_t vxy_reset_counter;
    uint8_t vz_reset_counter;
    uint8_t heading_reset_counter;
    uint8_t dist_bottom_sensor_bitfield;    // bitfield indicating what type of sensor is used to estimate dist_bottom
    bool xy_valid;                          // true if x and y are valid
    bool z_valid;                           // true if z is valid
    bool v_xy_valid;                        // true if vx and vy are valid
    bool v_z_valid;                         // true if vz is valid
    bool heading_good_for_control;          // 
    bool xy_global;                         // true if position (x, y) has a valid global reference (ref_lat, ref_lon)
    bool z_global;                          // true if z has a valid global reference (ref_alt)
    bool alt_valid;                         // 
    bool dist_bottom_valid;                 // true if distance to bottom surface is valid
    bool dead_reckoning;                    // True if this position is estimated through dead-reckoning
} uitc_vehicle_local_position;
/*----------------------------------variable----------------------------------*/

/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/

/*------------------------------------test------------------------------------*/

#ifdef __cplusplus
}
#endif



